const {
	contentTypeChange,
	pathChange,
	methodChange,
	introChange,
	onLoadSuccess,
} = require('./api-form-methods')

/**
 * 初始化接口信息表单
 * @param  {[type]} apiComp [description]
 * @return {[type]}         [description]
 */
module.exports = function initForm(apiComp) {
	let {
		formComp,
		formId,
		formContentType,
		formPath,
		formMethod,
		formIntro,
	} = apiComp
	formComp.form({
		onLoadSuccess(data) {
			onLoadSuccess.call(apiComp, data)
		}
	})

	formContentType.combobox({
		label: "请求类型:",
		onChange(newValue, oldValue) {
			contentTypeChange.call(apiComp, newValue, oldValue)
		},
	})
	formPath.textbox({
		label: '请求路径:',
		required: true,
		onChange(newValue, oldValue) {
			pathChange.call(apiComp, newValue, oldValue)
		},
	})
	formMethod.combobox({
		label: "请求方法:",
		onChange(newValue, oldValue) {
			methodChange.call(apiComp, newValue, oldValue)
		},
	})
	formIntro.textbox({
		label: '接口描述:',
		multiline: true,
		onChange(newValue, oldValue) {
			introChange.call(apiComp, newValue, oldValue)
		},
	})
}